package com.xxkj.orcfx.web;



import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**

 * @Description:

 */
public enum BaiduWordEnum {

    name("姓名", "name"),
    sex("性别", "sex"),
    nation("民族", "nation"),
    birthday("出生", "birthday"),
    address("住址", "address"),
    ident("公民身份号码", "ident"),

    validEnd("失效日期", "validEnd"),
    validBegin("签发日期", "validBegin"),
    issuer("签发机关", "issuer"),
    ;
    private String word;

    private String toWord;

    private static Map<String, String> enumMap = null;
    private BaiduWordEnum(String word, String toWord) {
        this.word = word;
        this.toWord = toWord;
    }

    public static String getTransByDesc(String desc) {
        if(StringUtils.isEmpty(desc)) {
            return desc;
        }
        if(enumMap == null) {
            enumMap = new HashMap<>();
            for (BaiduWordEnum e : BaiduWordEnum.values()) {
                enumMap.put(e.getWord(), e.getToWord());
            }
        }
        String name = enumMap.get(desc);
        if(name != null) return name;
        return desc;
    }

    public String getWord() {
        return word;
    }

    public String getToWord() {
        return toWord;
    }

    public static Map<String, String> getEnumMap() {
        if(enumMap == null) {
            enumMap = new HashMap<>();
            for (BaiduWordEnum e : BaiduWordEnum.values()) {
                enumMap.put(e.getWord(), e.getToWord());
            }
        }
        return enumMap;
    }
}
